package com.appspot.igo8poi.model.bean;

import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Poi {
	private static final int MAX_NAME_LENGTH = 500;

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

	@Persistent
	private Integer number;

    @Persistent
    private String userId;

	@Persistent
	private String groupName;

	@Persistent
	private String name;

	@Persistent
	private String latitude;

	@Persistent
	private String longitude;

	@Persistent
	private Date dateCreated;

	public Poi(String userId, String groupName, Integer number, String name, String latitude, String longitude) {
		this.number = number;
		this.userId = userId;
		this.name = name;
		this.groupName = groupName;
		this.latitude = latitude;
		this.longitude = longitude;
		this.dateCreated = new Date();
	}

	public Long getId() {
        return id;
    }

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getNumber() {
		return number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

    public String getUserId() {
        return userId;
    }

	public void setUserId(String userId) {
        this.userId = userId;
    }

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		if (null != name && name.length() > MAX_NAME_LENGTH) {
			name = name.substring(0, MAX_NAME_LENGTH - 1);
		}
		this.name = name;
	}

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
}